﻿@using Pay.Token.Utils
@model PagedResult<product_dto>
@{
    var img_url = ViewBag.img_url;
    if (Model.rows.Count > 0) {
        foreach (var item in Model.rows) {
            <div class="item">
                <div class="itemBox">
                    <div class="img">
                        <img src="@item.main_image_url" />
                    </div>
                    <div class="box">
                        <div class="text fn24">
                            <p class="tit">@item.name</p>
                            分销价：
                            @if (item.price > 0) {
                                <em class="col-red">@item.price.ToString("0.##")</em> <em class="fn20">元</em>
                            }
                            @if (item.price > 0 && (item.activity_ex != null && item.activity_ex.activity_red_drill > 0)) {
                                <em class="fn20">+</em>
                            }

                            @if (item.activity_ex != null && item.activity_ex.activity_red_drill > 0) {
                                <em class="col-red">@item.activity_ex.activity_red_drill.ToString("0.######")</em> <em class="fn20">红钻</em>
                            }
                            <br>
                            佣金：<em class="col-red">@(DistributionHelper.GetProfitByLevel(item.distribution_price.GetValueOrDefault(0), ViewBag.UserType).ToString("f2"))</em><em class="fn20">元</em> <br>
                            库存：<em class="">@item.stock</em><em class="fn20">@(!string.IsNullOrEmpty(item.unit) && item.unit != "null" ? item.unit : "件")</em> <br>
                            邮费：@if (item.freight.GetValueOrDefault(0) > 0) {
                                <em class="col-red">@item.freight.GetValueOrDefault(0).ToString("f2")</em><em class="fn20">元</em>
                            } else { <em class="col-red">包邮</em>
                            }
                        </div>
                        <div class="boxBtn mt20">
                            @if (!item.is_distribution) {
                                <a class="ui-btn-share ui-btn-share-100 add_share" href="javascript:void(0)" data-id="@item.id">添加分销</a>
                            } else {
                                <a class="ui-btn-default ui-btn-share-100 " href="javascript:void(0)">已添加</a>
                            }
                        </div>
                    </div>
                </div>
            </div>
        }
    }
    <page total_pages="@Model.total_pages" rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}
